package com.css.dzj.dzjportal.common.util.userinfo;

import com.css.dzj.dzjportal.common.util.Restful.RestfulUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 修改密码
 * @Author WT
 * @Date 2020/7/23
 */
@Component
@PropertySource(value = "classpath:base.properties")
public class UserInfoService {
    @Value("${BASE_URL}")
    private String BASE_URL;
    @Value("${APP_CODE}")
    private String APP_CODE;

    /**
     * 修改密码
    *@Author weitao
    *@Date 10:03 2020/7/23
    */
    public String updatePassword(String oldPassword ,String password, String userId, HttpServletRequest request) {
        String url = BASE_URL + "/platform/api/org/users/" + userId + "/certification";
        HttpMethod method = HttpMethod.PUT;
        Map map = new HashMap();
        map.put("oldCipher",oldPassword);
        map.put("newCipher", password);
        map.put("appCode", APP_CODE);
        String body = (String) RestfulUtil.sendRestful(request, map, url, method).get("data");
        // Map body = (Map) RestfulUtil.sendRestflu(request, map, url, method).get("data");
        return body;
    }
}
